<!--   
Persistent Digital Archives and Library System (PeDALS) 
(c) 2008 - All Rights Reserved
//-->
<?php
if ((is_file('includes\config.php')) and (is_file('includes\header.php')) and (is_file('includes\footer.php')) and (is_file('includes\style.css'))) {
	include 'includes\config.php';
} else {
	echo "Unable to locate one or all of the include files.  Please contact your PeDALS Administrator.";
	die;
}
$itemId = urldecode(@$_GET["id"]);
/* query string not correct */
if ($itemId == "") {
	echo "Item not found.  You did not select a valid item for viewing.";
	die;
}
$params = array(&$itemId);	

$tsqlGeneral = "SELECT     TOP (1) Series.SeriesTitle, SeriesAcquisition.SeriesAcquisitionId, SeriesAcquisition.SeriesAcquisitionReadyToIngest, 
                      SeriesAcquisition.SeriesAcquisitionAccessionNumber, CONVERT(VARCHAR, SeriesAcquisition.SeriesAcquisitionIngestDate, 101) 
                      AS SeriesAcquisitionIngestDate, SeriesAcquisition.SeriesAcquisitionIngested, SeriesAcquisition.SeriesAcquisitionDirectory, 
                      SeriesAcquisitionItem_LINK.ItemId
FROM         Series LEFT OUTER JOIN
                      SeriesAcquisitionItem_LINK ON Series.SeriesId = SeriesAcquisitionItem_LINK.SeriesId INNER JOIN
                      SeriesAcquisition ON SeriesAcquisitionItem_LINK.SeriesAcquisitionId = SeriesAcquisition.SeriesAcquisitionId AND 
                      Series.SeriesId = SeriesAcquisition.SeriesId
WHERE     (SeriesAcquisitionItem_LINK.ItemId = (?))";


 	$getData = sqlsrv_prepare( $conn, $tsqlGeneral, $params);
 	if( $getData === false ) {
		 echo "Error in preparing statement.\n";
		 die( print_r( sqlsrv_errors(), true));
	}
	/* Execute the statement. Display any errors that occur. */
	if( sqlsrv_execute( $getData))
	{   
	/*echo "Statement executed.\n";*/
	}
	else
	{
		 echo "Error in executing statement.\n";
		 die( print_r( sqlsrv_errors(), true));
	}
	$rowCount = 0;
 	while (sqlsrv_fetch( $getData ))
	{	
		$seriestitle = sqlsrv_get_field($getData, 0);
		$acqid = sqlsrv_get_field($getData, 1);
		$readytoingest = sqlsrv_get_field($getData, 2);
		$accessionno = sqlsrv_get_field($getData, 3);
		$ingestdate = sqlsrv_get_field($getData, 4);
		$ingested = sqlsrv_get_field($getData, 5);
		$directory = sqlsrv_get_field($getData, 6);		
		$rowCount++;
	}
	/* series id in query string is wrong */
	if( $rowCount == 0 ) { 
	echo "Item not found.  You did not select a valid item for viewing.<br/><br/><br/><br/>";
	die;
    	}
 ?>   
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
    <meta name="description" content="Persistent Digital Archives and Library System" />
    <title>PeDALS Web Administration: Item Level Review</title>
    <link rel="shortcut icon" href="images/favicon.ico" />
    <link href="includes/style.css" rel="stylesheet" type="text/css" />
</head>
<body>
<?php include 'includes\header.php'; ?>
<div id="breadcrumb-container">
  <div id="breadcrumb"><a href="index.php" title=Home page">Home</a> / <a href="acqSummary.php" title="Acquisitions">Acquisitions</a> / <a href="acqDetail.php?acq=<?php echo $acqid ?>" title="Acquisitions">Acquisition Detail</a> / <a href="itemSummary.php?acq=<?php echo $acqid ?>" title="Item Review">Item Level Review</a> / Item Detail</div>
  <div id="breadcrumb-side"><form name="search" action="search.php"><input type="text" name="q" width="50"/><input type="submit" value="Go" /></form><a href="advSearch.php" title="Advanced Search" alt="Advanced Search">Advanced Search</a>
  </div>
  <div class="clear"></div>
</div>
<!-- 
  CONTENT
  -->
<div id="content-container">
<br/>

 <?php 
	$tsqlItem = "SELECT * FROM Item WHERE ItemId = (?)";
 	$getData = sqlsrv_prepare( $conn, $tsqlItem, $params);
 	if( $getData === false ) {
		 echo "Error in preparing statement.\n";
		 die( print_r( sqlsrv_errors(), true));
	}
	/* Execute the statement. Display any errors that occur. */
	if( sqlsrv_execute( $getData))
	{   
	/*echo "Statement executed.\n";*/
	}
	else
	{
		 echo "Error in executing statement.\n";
		 die( print_r( sqlsrv_errors(), true));
	}
	$rowCount = 0;
 	while (sqlsrv_fetch( $getData ))
	{	
		$id = sqlsrv_get_field($getData, 0);
		$seriesid = sqlsrv_get_field($getData, 1);
		$title = sqlsrv_get_field($getData, 2);
		$rowCount++;
	}
	/* item id in query string is wrong */
	if( $rowCount == 0 ) { 
	echo "Item not found.  You did not select a valid item for viewing.<br/><br/><br/><br/>";
	die;
    	}
 ?> 
<h1 align="middle"><?php echo $title; ?></h1>   
<?php
	if ($readytoingest == 4) {
		echo "<form method=\"post\">";
		echo "<input type=\"submit\" style=\"background-color:lightgreen;\" value=\"Extract item file\" onClick='alert(\"This requires a script to extract file from LOCKSS\")';\"/>";
		echo "</form>";
    }
	?>
<table width="100%" cellpadding="5px" style="font-size:1.0em;">
<tr>
<?php 
	if (($readytoingest == 5) or ($readytoingest == 3)) { 
	echo "<td width=\"30%\" valign=\"top\">";
    } else {
    echo "<td width=\"100%\" valign=\"top\">";
}
 
	$tsql = "SELECT ItemId, SeriesId, ItemTitle, ItemDisplayTitle, ItemDescription, ItemExtentDescription, CONVERT(VARCHAR, ItemOpenDate, 101) AS ItemOpenDate, ItemSample, ItemReceivedFileName, ItemOriginatorIdentifier, ItemLanguage, ItemAccessFacilitators, ItemExceptions, HardwareId, OperatingSystemId, SoftwareId, DigestAlgorithmId, ItemReceivedHashOriginator, CONVERT(VARCHAR, ItemReceivedHashDate, 101) AS ItemReceivedHashDate, ItemReceivedHashValue, ItemReceivedHashType, ItemTechnicalInfrastructure, ItemGeneralNote, DigitalFormatId, FilingUnitId, SuperPackageId, ItemPURL, CONVERT(VARCHAR, CreatedDate, 101) AS CreatedDate, CreatedBy, CONVERT(VARCHAR, ModifiedDate, 101) AS ModifiedDate, ModifiedBy FROM Item WHERE ItemId = (?)";
 	$getData = sqlsrv_prepare( $conn, $tsql, $params);
 	if( $getData === false ) {
		 echo "Error in preparing statement.\n";
		 die( print_r( sqlsrv_errors(), true));
	}
	/* Execute the statement. Display any errors that occur. */
	if( sqlsrv_execute( $getData))
	{   
	/*echo "Statement executed.\n";*/
	}
	else
	{
		 echo "Error in executing statement.\n";
		 die( print_r( sqlsrv_errors(), true));
	}
	$rowCount = 0;
 	while (sqlsrv_fetch( $getData ))
	{	
		$itemid = sqlsrv_get_field($getData, 0);
		$seriesid = sqlsrv_get_field($getData, 1);
		$title = sqlsrv_get_field($getData, 2);
		$displaytitle = sqlsrv_get_field($getData, 3);
		$opendate = sqlsrv_get_field($getData, 6);
		$receivedfilename = sqlsrv_get_field($getData, 8);
		$originatorid = sqlsrv_get_field($getData, 9);
		$language = sqlsrv_get_field($getData, 10);
		$accessfacilitators = sqlsrv_get_field($getData, 11);
		$exceptions = sqlsrv_get_field($getData, 12);
		$hardwareid = sqlsrv_get_field($getData, 13);	
		$operatingsystemid = sqlsrv_get_field($getData, 14);	
		$softwareid = sqlsrv_get_field($getData, 15);	
		$digestalgorithmid = sqlsrv_get_field($getData, 16);	
		$hashoriginator = sqlsrv_get_field($getData, 17);
		$hashdate = sqlsrv_get_field($getData, 18);
		$hashvalue = sqlsrv_get_field($getData, 19);
		$hashtype = sqlsrv_get_field($getData, 20);
		$technicalinfrastructure = sqlsrv_get_field($getData, 21);
		$generalnote = sqlsrv_get_field($getData, 22);						
		$digitalformatid = sqlsrv_get_field($getData, 23);			
		$filingunitid = sqlsrv_get_field($getData, 24);	
		$superpackage = sqlsrv_get_field($getData, 25);	
		$purl = sqlsrv_get_field($getData, 26);			
		$createdon = sqlsrv_get_field($getData, 27);
		$createdby = sqlsrv_get_field($getData, 28);
		$modifiedon = sqlsrv_get_field($getData, 29);
		$modifiedby = sqlsrv_get_field($getData, 30);
		$rowCount++;
	}
	/* series id in query string is wrong */
	if( $rowCount == 0 ) { 
	echo "Item not found.  You did not select a valid item for viewing.<br/><br/><br/><br/>";
	die;
    	}
    
$tsqlProv = "SELECT Provenance.ProvenanceName FROM Provenance INNER JOIN Series ON Provenance.ProvenanceId = Series.ProvenanceId WHERE (Series.SeriesId = $seriesid)";
 	$getData = sqlsrv_prepare( $conn, $tsqlProv, $params);
 	if( $getData === false ) {
		 echo "Error in preparing statement.\n";
		 die( print_r( sqlsrv_errors(), true));
	}
	/* Execute the statement. Display any errors that occur. */
	if( sqlsrv_execute( $getData))
	{   
	/*echo "Statement executed.\n";*/
	}
	else
	{
		 echo "Error in executing statement.\n";
		 die( print_r( sqlsrv_errors(), true));
	}
	$rowCount = 0;
 	while (sqlsrv_fetch( $getData ))
	{	
		$provname = sqlsrv_get_field($getData, 0);
		$rowCount++;
	}
	/* item id in query string is wrong */
	if( $rowCount == 0 ) { 
	echo "Item not found.  You did not select a valid item for viewing.<br/><br/><br/><br/>";
	die;
    	} 
?>
<h1 align="left">Item Metadata</h1> 
<p align="left"><strong>Provenance</strong>: <?php echo $provname; ?><br/>
<strong>Series</strong>: <?php echo $seriestitle; ?></p>

<p align="left"><strong>Accession Number</strong>: <?php echo $accessionno; ?><br/>
<strong>Acquisition Ingest Identifier</strong>: <?php echo $acqid; ?><br/>
<strong>Status</strong>: 
<?php 
	switch ($readytoingest) {
    case 0:
		echo "Waiting for submission.";
        break;
    case 1:
		echo "Accepted. BizTalk creating superpackage.";	
        break;
    case 2:
		echo "Rejected. BizTalk removing records.";	
        break;
    case 3:
		echo "Rejected at least once. Waiting for resubmission.";
        break;		
    case 4:
        echo "Superpackage has been created.";
        break;	
	case 5:
		echo "Ready for review.";
        break;		
    case 9:
        echo "BizTalk processing submitted records.";
        break;		
}

 ?></p> 
<?php 
	$tsqlF = "SELECT FilingUnitName FROM FilingUnit WHERE FilingUnitId = $filingunitid";
	$getData = sqlsrv_prepare( $conn, $tsqlF, $params);
	if( $getData )
	{ 	}
	else
	{
		 echo "Error in preparing statement.\n";
		 die( print_r( sqlsrv_errors(), true));
	}

	/* Execute the statement. Display any errors that occur. */
	if( sqlsrv_execute( $getData))
	{ 	}

	$rowCount = 0;	
	while (sqlsrv_fetch( $getData ))
	{
		$filingunitname = sqlsrv_get_field($getData, 0);
		echo "<p align=\"left\"><strong>Filing Unit Name</strong>:" .$filingunitname. "</p>";
		$rowCount++;
    }
		
	if( $rowCount == 0 ) { 
	    echo "<p align=\"left\"><strong>Filing Unit Name</strong>:</p>"; 
    	}
	?>
	
<p align="left"><strong>Item Title</strong>: <?php echo $title; ?><br/>
<strong>Variant Title(s)</strong>:
<?php
 $tsqlVarT = "SELECT ItemVariantTitle FROM ItemVariantTitle WHERE ItemId = (?) ORDER BY ItemVariantTitle";
 $getData = sqlsrv_prepare( $conn, $tsqlVarT, $params);
 	if( $getData === false ) {
		 echo "Error in preparing statement.\n";
		 die( print_r( sqlsrv_errors(), true));
	}
	/* Execute the statement. Display any errors that occur. */
	if( sqlsrv_execute( $getData))
	{   
	/*echo "Statement executed.\n";*/
	}
	else
	{
		 echo "Error in executing statement.\n";
		 die( print_r( sqlsrv_errors(), true));
	}
	$rowCount = 0;	
 	while (sqlsrv_fetch( $getData ))
	{	
		$vartitle = sqlsrv_get_field($getData, 0);
		echo '<br/>';
		echo $vartitle;
		$rowCount++;	
	}    
	if( $rowCount == 0 ) { 
	    echo ""; 
    	}
?>
<br/>
<strong>Display Title</strong>: <?php echo $displaytitle; ?></p>

<p align="left"><strong>Item Date(s)</strong>:
<?php	
$tsqlDate = "SELECT Qualifier.QualifierType, ItemDate.ItemDateValue FROM Qualifier INNER JOIN ItemDate ON Qualifier.QualifierId = ItemDate.QualifierId WHERE ItemDate.ItemId = (?) ORDER BY Qualifier.QualifierType, ItemDate.ItemDateValue";
	/* Create the statement. */

	$getData = sqlsrv_prepare( $conn, $tsqlDate, $params);
	if( $getData )
	{ 	}
	else
	{
		 echo "Error in preparing statement.\n";
		 die( print_r( sqlsrv_errors(), true));
	}

	/* Execute the statement. Display any errors that occur. */
	if( sqlsrv_execute( $getData))
	{ 	}
	else
	{
		 echo "Error in executing statement.\n";
		 die( print_r( sqlsrv_errors(), true));
	}
	$rowCount = 0;
	
	while (sqlsrv_fetch( $getData ))
	{
		$dateQual = sqlsrv_get_field($getData, 0);
		$dateName = sqlsrv_get_field($getData, 1);
		echo "<br/>";
		echo $dateQual;
		echo ": ";
		echo $dateName;
		$rowCount++;
    }	

	
	if( $rowCount == 0 ) { 
	    echo ""; 
    	}
	
?>
</p>


<p align="left"><strong>Item Extent</strong>: 
<?php 
$tsqlE = "SELECT ItemExtentDescription FROM Item WHERE ItemId = (?)";
$stmt = sqlsrv_query( $conn, $tsqlE, $params);

while ($rr=sqlsrv_fetch_array($stmt, SQLSRV_FETCH_BOTH)){
	echo $rr[0];
}
 ?></p>

<p align="left"><strong>Item Description</strong>: 
<?php 
$tsqlD = "SELECT ItemDescription FROM Item WHERE ItemId = (?)";
$stmt = sqlsrv_query( $conn, $tsqlD, $params);

while ($rr=sqlsrv_fetch_array($stmt, SQLSRV_FETCH_BOTH)){
	echo $rr[0];
}
 ?></p>

<p align="left"><strong>Item Sample Text</strong>:
<?php 
$tsqlS = "SELECT ItemSample FROM Item WHERE ItemId = (?)";
$stmt = sqlsrv_query( $conn, $tsqlS, $params);

while ($rr=sqlsrv_fetch_array($stmt, SQLSRV_FETCH_BOTH)){
	echo $rr[0];
}
 ?></p>     

<p align="left"><strong>Item General Note</strong>:
<?php 
$tsqlN = "SELECT ItemGeneralNote FROM Item WHERE ItemId = (?)";
$stmt = sqlsrv_query( $conn, $tsqlN, $params);

while ($rr=sqlsrv_fetch_array($stmt, SQLSRV_FETCH_BOTH)){
	echo $rr[0];
}
 ?></p>     
 
<p align="left">
<strong>Item Parties and Roles</strong>: 
<?php	
$tsqlPart = "SELECT Qualifier.QualifierType, ItemParty.ItemPartyValue FROM Qualifier INNER JOIN ItemParty ON Qualifier.QualifierId = ItemParty.QualifierId WHERE ItemParty.ItemId = (?) ORDER BY Qualifier.QualifierType, ItemParty.ItemPartyValue";
	/* Create the statement. */

	$getData = sqlsrv_prepare( $conn, $tsqlPart, $params);
	if( $getData )
	{ 	}
	else
	{
		 echo "Error in preparing statement.\n";
		 die( print_r( sqlsrv_errors(), true));
	}

	/* Execute the statement. Display any errors that occur. */
	if( sqlsrv_execute( $getData))
	{ 	}
	else
	{
		 echo "Error in executing statement.\n";
		 die( print_r( sqlsrv_errors(), true));
	}
	$rowCount = 0;
	
	while (sqlsrv_fetch( $getData ))
	{
		$partyQual = sqlsrv_get_field($getData, 0);
		$partyName = sqlsrv_get_field($getData, 1);
		echo "<br/>";
		echo $partyQual;
		echo ": ";
		echo $partyName;
		$rowCount++;
    }	

	
	if( $rowCount == 0 ) { 
	    echo ""; 
    	}
	
?>
</p>

<p align="left"><strong>Item Subject(s):</strong>
<?php	
$tsqlSubj = "SELECT Qualifier.QualifierType, ItemSubject_LINK.SubjectId FROM Qualifier INNER JOIN ItemSubject_LINK ON Qualifier.QualifierId = ItemSubject_LINK.QualifierId WHERE ItemSubject_LINK.ItemId = (?) ORDER BY Qualifier.QualifierType, ItemSubject_LINK.SubjectId";
	/* Create the statement. */

	$getData = sqlsrv_prepare( $conn, $tsqlSubj, $params);
	if( $getData )
	{ 	}
	else
	{
		 echo "Error in preparing statement.\n";
		 die( print_r( sqlsrv_errors(), true));
	}

	/* Execute the statement. Display any errors that occur. */
	if( sqlsrv_execute( $getData))
	{ 	}
	else
	{
		 echo "Error in executing statement.\n";
		 die( print_r( sqlsrv_errors(), true));
	}
	$rowCount = 0;
	
	while (sqlsrv_fetch( $getData ))
	{
		$subQual = sqlsrv_get_field($getData, 1);
		$subName = sqlsrv_get_field($getData, 2);
		echo "<br/>";
		echo $subQual;
		echo ": ";
		echo $subName;
		$rowCount++;
    }	

	
	if( $rowCount == 0 ) { 
	    echo ""; 
    	}
	
?>
</p>

<p align="left"><strong>Item Geographic Location(s):</strong>
<?php 
$tsqlLoc = "SELECT GeoLocation.GeoLocationValue FROM ItemGeoLocation_LINK INNER JOIN GeoLocation ON ItemGeoLocation_LINK.GeoLocationId = GeoLocation.GeoLocationId WHERE ItemGeoLocation_LINK.ItemId = (?) ORDER BY GeoLocation.GeoLocationValue";
 $getData = sqlsrv_prepare( $conn, $tsqlLoc, $params);
 	if( $getData === false ) {
		 echo "Error in preparing statement.\n";
		 die( print_r( sqlsrv_errors(), true));
	}
	/* Execute the statement. Display any errors that occur. */
	if( sqlsrv_execute( $getData))
	{   
	/*echo "Statement executed.\n";*/
	}
	else
	{
		 echo "Error in executing statement.\n";
		 die( print_r( sqlsrv_errors(), true));
	}
	$rowCount = 0;	
 	while (sqlsrv_fetch( $getData ))
	{	
		$location = sqlsrv_get_field($getData, 0);
		echo '<br/>';
		echo $location;
		$rowCount++;	
	}    
	if( $rowCount == 0 ) { 
	    echo ""; 
    	}
?>
</p>
 
<p align="left"><strong>Item Keyword(s):</strong>
<?php
 $tsqlKey = "SELECT Keyword FROM ItemKeyword WHERE ItemId = (?) ORDER BY Keyword";
 $getData = sqlsrv_prepare( $conn, $tsqlKey, $params);
 	if( $getData === false ) {
		 echo "Error in preparing statement.\n";
		 die( print_r( sqlsrv_errors(), true));
	}
	/* Execute the statement. Display any errors that occur. */
	if( sqlsrv_execute( $getData))
	{   
	/*echo "Statement executed.\n";*/
	}
	else
	{
		 echo "Error in executing statement.\n";
		 die( print_r( sqlsrv_errors(), true));
	}
	$rowCount = 0;	
 	while (sqlsrv_fetch( $getData ))
	{	
		$keyword = sqlsrv_get_field($getData, 0);
		echo '<br/>';
		echo $keyword;
		$rowCount++;	
	}    
	if( $rowCount == 0 ) { 
	    echo ""; 
    	}
?>
</p>

<p align="left"><strong>Item Originator Identifier</strong>: <?php echo $originatorid; ?></p>

<!--NOT FUNCTIONAL YET-->
<p align="left"><strong>Related Item</strong>: </p>

<p align="left"><strong>Item Language</strong>: <?php echo $language; ?></p>

<?php 
	$tsqlDF = "SELECT DigitalFormatFileType, DigitalFormatRenderingSoftwareName, DigitalFormatRenderingSoftwareVersion, DigitalFormatRegistryId, DigitalFormatMIMEType FROM DigitalFormat WHERE DigitalFormatId = $digitalformatid";
					  
	$getData = sqlsrv_prepare( $conn, $tsqlDF, $params);
	if( $getData )
	{ 	}
	else
	{
		 echo "Error in preparing statement.\n";
		 die( print_r( sqlsrv_errors(), true));
	}

	/* Execute the statement. Display any errors that occur. */
	if( sqlsrv_execute( $getData))
	{ 	}

	$rowCount = 0;	
	while (sqlsrv_fetch( $getData ))
	{
		$digformatfiletype = sqlsrv_get_field($getData, 0);
		$digformatname = sqlsrv_get_field($getData, 1);
		$digformatversion = sqlsrv_get_field($getData, 2);
		$registryid = sqlsrv_get_field($getData, 3);
		$mimetype = sqlsrv_get_field($getData, 4);													
		$rowCount++;
    }
		
	if( $rowCount == 0 ) { 
	    $digformatfiletype = "";
	    $digformatname = "";
	    $digformatversion = "";
		$registryid = "";
		$mimetype = "";
    	}
	?>
    
<p align="left"><strong>Item MIME Type</strong>:  <?php echo $mimetype ?></p>

<p align="left"><strong>Unique Item Identifier</strong>: <?php echo $itemid; ?></p>

<p align="left"><strong>Item Received File Name</strong>: <?php echo $receivedfilename; ?></p>

<p align="left"><strong>Item Superpackage ID</strong>:  <?php echo $superpackage; ?></p>

<p align="left"><strong>Item Other Identifier(s)</strong>:
<?php	
$tsqlId = "SELECT Qualifier.QualifierType, ItemOtherIdentifier.ItemOtherIdentifierValue FROM ItemOtherIdentifier INNER JOIN Qualifier ON ItemOtherIdentifier.QualifierId = Qualifier.QualifierId WHERE ItemOtherIdentifier.ItemId = (?) ORDER BY Qualifier.QualifierType, ItemOtherIdentifier.ItemOtherIdentifierValue";
	/* Create the statement. */

	$getData = sqlsrv_prepare( $conn, $tsqlId, $params);
	if( $getData )
	{ 	}
	else
	{
		 echo "Error in preparing statement.\n";
		 die( print_r( sqlsrv_errors(), true));
	}

	/* Execute the statement. Display any errors that occur. */
	if( sqlsrv_execute( $getData))
	{ 	}
	else
	{
		 echo "Error in executing statement.\n";
		 die( print_r( sqlsrv_errors(), true));
	}
	$rowCount = 0;
	
	while (sqlsrv_fetch( $getData ))
	{
		$idQual = sqlsrv_get_field($getData, 0);
		$idName = sqlsrv_get_field($getData, 1);
		echo "<br/>";
		echo $idQual;
		echo ": ";
		echo $idName;
		$rowCount++;
    }	

	
	if( $rowCount == 0 ) { 
	    echo ""; 
    	}
	
?>
</p>

<p align="left"><strong>Item PURL</strong>:  <?php echo $purl; ?></p>

<p align="left"><strong>Item Open Date</strong>: <?php echo $opendate; ?></p>

<p align="left"><strong>Item Access Facilitators</strong>: <?php echo $accessfacilitators; ?></p>

<?php	
$parameter = array(&$operatingsystemid);
$tsqlOS = "SELECT * FROM OperatingSystem WHERE OperatingSystemId = (?)";
	/* Create the statement. */

	$getData = sqlsrv_prepare( $conn, $tsqlOS, $parameter);
	if( $getData )
	{ 	}
	else
	{
		 echo "Error in preparing statement.\n";
		 die( print_r( sqlsrv_errors(), true));
	}

	/* Execute the statement. Display any errors that occur. */
	if( sqlsrv_execute( $getData))
	{ 	}
	else
	{
		 echo "Error in executing statement.\n";
		 die( print_r( sqlsrv_errors(), true));
	}
	$rowCount = 0;
	
	while (sqlsrv_fetch( $getData ))
	{
		$OSname = sqlsrv_get_field($getData, 1);	
		$OSversion = sqlsrv_get_field($getData, 2);
		$OSlocation = sqlsrv_get_field($getData, 3);
		$OSdocumentation = sqlsrv_get_field($getData, 4);
		$rowCount++;
    }	

	
	if( $rowCount == 0 ) { 
		$OSname = "";	
		$OSversion = "";
		$OSlocation = "";
		$OSdocumentation = "";
    	}
	
?>
<p align="left">
<strong>Item Operating System Name</strong>: <?php echo $OSname; ?><br/>
<strong>Item Operating System Location</strong>: <?php echo $OSlocation; ?><br/>
<strong>Item Operating System Documentation</strong>: <?php echo $OSdocumentation; ?><br/>
<strong>Item Operating System Version</strong>: <?php echo $OSversion; ?>
</p>

<?php	
$parameter = array(&$hardwareid);
$tsqlHD = "SELECT * FROM Hardware WHERE HardwareId = (?)";
	/* Create the statement. */

	$getData = sqlsrv_prepare( $conn, $tsqlHD, $parameter);
	if( $getData )
	{ 	}
	else
	{
		 echo "Error in preparing statement.\n";
		 die( print_r( sqlsrv_errors(), true));
	}

	/* Execute the statement. Display any errors that occur. */
	if( sqlsrv_execute( $getData))
	{ 	}
	else
	{
		 echo "Error in executing statement.\n";
		 die( print_r( sqlsrv_errors(), true));
	}
	$rowCount = 0;
	
	while (sqlsrv_fetch( $getData ))
	{
		$HDname = sqlsrv_get_field($getData, 1);	
		$HDtype = sqlsrv_get_field($getData, 2);
		$HDlocation = sqlsrv_get_field($getData, 3);
		$HDdocumentation = sqlsrv_get_field($getData, 4);
		$rowCount++;
    }	

	
	if( $rowCount == 0 ) { 
		$HDname = "";	
		$HDtype = "";
		$HDlocation = "";
		$HDdocumentation = "";
    	}
	
?>
<p align="left">
<strong>Item Hardware Name</strong>:  <?php echo $HDname; ?><br/>
<strong>Item Hardware Type</strong>:  <?php echo $HDtype; ?><br/>
<strong>Item Hardware Location</strong>:  <?php echo $HDlocation; ?><br/>
<strong>Item Hardware Documentation</strong>:  <?php echo $HDdocumentation; ?>
</p>

<p align="left"><strong>Item Exceptions</strong>: <?php echo $exceptions; ?></p>

<?php 
	$tsqlSig = "SELECT ItemSignatureSigner, ItemSignatureInformationEncoding, ItemSignatureValue, ItemSignatureMethod, ItemSignatureProperties, DigitalSignatureKeyId FROM ItemSignature WHERE ItemId = (?)";
					  
	$getData = sqlsrv_prepare( $conn, $tsqlSig, $params);
	if( $getData )
	{ 	}
	else
	{
		 echo "Error in preparing statement.\n";
		 die( print_r( sqlsrv_errors(), true));
	}

	/* Execute the statement. Display any errors that occur. */
	if( sqlsrv_execute( $getData))
	{ 	}

	$rowCount = 0;	
	while (sqlsrv_fetch( $getData ))
	{
		$signer = sqlsrv_get_field($getData, 0);
		$encoding = sqlsrv_get_field($getData, 1);	
		$sigvalue = sqlsrv_get_field($getData, 2);			
		$method = sqlsrv_get_field($getData, 3);
		$properties = sqlsrv_get_field($getData, 4);
		$digsigkeyid = sqlsrv_get_field($getData, 5);
		$rowCount++;
    }
		
	if( $rowCount == 0 ) { 
	    $signer = "";
	    $encoding = "";
		$sigvalue = "";
	    $method = "";
	    $properties = "";	
		$digsigkeyid = "";				
    	}
	?>
    
<p align="left">
<strong>Item Signer</strong>:  <?php echo $signer; ?><br/>
<strong>Item Signature Information Encoding</strong>:  <?php echo $encoding; ?><br/>
<strong>Item Signature Method</strong>:  <?php echo $method; ?><br/>
<strong>Item Signature Value</strong>:  <?php echo $sigvalue; ?><br/>
<strong>Item Signature Properties</strong>:  <?php echo $properties; ?>
</p>

<?php 
	$tsqlKey = "SELECT DigitalSignatureKeyType, DigitalSignatureKeyValue FROM DigitalSignatureKey WHERE DigitalSignatureKeyId = $digsigkeyid";
					  
	$getData = sqlsrv_prepare( $conn, $tsqlKey, $params);
	if( $getData )
	{ 	}
	else
	{
		 echo "Error in preparing statement.\n";
		 die( print_r( sqlsrv_errors(), true));
	}

	/* Execute the statement. Display any errors that occur. */
	if( sqlsrv_execute( $getData))
	{ 	}

	$rowCount = 0;	
	while (sqlsrv_fetch( $getData ))
	{
		$keytype = sqlsrv_get_field($getData, 0);	
		$keyvalue = sqlsrv_get_field($getData, 1);			
		$rowCount++;
    }
		
	if( $rowCount == 0 ) { 
	    $keytype = "";
	    $keyvalue = "";			
    	}
	?>
<p align="left">
<strong>Item Key Information</strong>:   
<?php 
if ($digsigkeyid != "") {
$tsqlKI = "SELECT DigitalSignatureKeyInformation FROM DigitalSignatureKey WHERE DigitalSignatureKeyId = $digsigkeyid";
$stmt = sqlsrv_query( $conn, $tsqlKI, $params);

while ($rr=sqlsrv_fetch_array($stmt, SQLSRV_FETCH_BOTH)){
	echo $rr[0];
}
}
 ?><br/>
<strong>Item Key Type</strong>:  <?php echo $keytype; ?><br/>
<strong>Item Key Value</strong>:  <?php echo $keyvalue; ?><br/>
<strong>Item Key Verification Information</strong>:   
<?php 
if ($digsigkeyid != "") {
$tsqlKV = "SELECT DigitalSignatureKeyVerification FROM DigitalSignatureKey WHERE DigitalSignatureKeyId = $digsigkeyid";
$stmt = sqlsrv_query( $conn, $tsqlKV, $params);

while ($rr=sqlsrv_fetch_array($stmt, SQLSRV_FETCH_BOTH)){
	echo $rr[0];
}
}
 ?>
</p>
<?php 
	$tsqlDF = "SELECT DigitalFormatRegistryRole.DigitalFormatRegistryRoleName, DigitalFormatRegistry.DigitalFormatRegistryName
FROM DigitalFormatRegistryRole INNER JOIN DigitalFormatRegistry ON DigitalFormatRegistryRole.DigitalFormatRegistryRoleId = DigitalFormatRegistry.DigitalFormatRegistryRoleId CROSS JOIN Item WHERE Item.ItemId = (?)";
					  
	$getData = sqlsrv_prepare( $conn, $tsqlDF, $params);
	if( $getData )
	{ 	}
	else
	{
		 echo "Error in preparing statement.\n";
		 die( print_r( sqlsrv_errors(), true));
	}

	/* Execute the statement. Display any errors that occur. */
	if( sqlsrv_execute( $getData))
	{ 	}

	$rowCount = 0;	
	while (sqlsrv_fetch( $getData ))
	{
		$rolename = sqlsrv_get_field($getData, 0);
		$registryname = sqlsrv_get_field($getData, 1);												
		$rowCount++;
    }
		
	if( $rowCount == 0 ) { 
	    $rolename = "";
	    $registryname = "";

    	}
	?>
<p align="left">
<strong>Item Format File Type</strong>:  <?php echo $digformatfiletype; ?><br/>
<strong>Item Format MIME Type</strong>:  <?php echo $mimetype; ?><br/>
<strong>Item Format Name</strong>:  <?php echo $digformatname; ?><br/>
<strong>Item Format Version</strong>:  <?php echo $digformatversion; ?><br/>
<strong>Item Format Registry Name</strong>:  <?php echo $registryname; ?><br/>

<!--WHICH SQL FIELD?????-->
<strong>Item Format Registry Key</strong>:  <br/>
<strong>Item Format Registry Role</strong>:  <?php echo $rolename; ?>
</p>

<?php 
	$tsqlDA = "SELECT DigestAlgorithmName, DigestAlgorithmId FROM DigestAlgorithm WHERE DigestAlgorithmId = $digestalgorithmid";
	$getData = sqlsrv_prepare( $conn, $tsqlDA, $params);
	if( $getData )
	{ 	}
	else
	{
		 echo "Error in preparing statement.\n";
		 die( print_r( sqlsrv_errors(), true));
	}

	/* Execute the statement. Display any errors that occur. */
	if( sqlsrv_execute( $getData))
	{ 	}

	$rowCount = 0;	
	while (sqlsrv_fetch( $getData ))
	{
		$digestalgorithmname = sqlsrv_get_field($getData, 0);														
		$rowCount++;
    }
		
	if( $rowCount == 0 ) { 
	    $digestalgorithmname = "";
    	}
	?>

<p align="left">
<strong>Item Digest Algorithm</strong>:  <?php echo $hashtype; ?><br/>
<strong>Item Digest Value</strong>:  <?php echo $hashvalue; ?><br/>
<strong>Item Digest Originator</strong>:  <?php echo $hashoriginator; ?><br/>
<strong>Item Digest Time</strong>:  <?php echo $hashdate; ?>
</p>


<?php 
	$tsqlSF = "SELECT SoftwareName, SoftwareVersion FROM Software WHERE SoftwareId = $softwareid";
	$getData = sqlsrv_prepare( $conn, $tsqlSF, $params);
	if( $getData )
	{ 	}
	else
	{
		 echo "Error in preparing statement.\n";
		 die( print_r( sqlsrv_errors(), true));
	}

	/* Execute the statement. Display any errors that occur. */
	if( sqlsrv_execute( $getData))
	{ 	}

	$rowCount = 0;	
	while (sqlsrv_fetch( $getData ))
	{
		$softwarename = sqlsrv_get_field($getData, 0);	
		$softwareversion = sqlsrv_get_field($getData, 1);																	
		$rowCount++;
    }
		
	if( $rowCount == 0 ) { 
	    $softwarename = "";
	    $softwareversion = "";			
    	}
	?>

<p align="left">
<strong>Item Rendering Software Name</strong>:  <?php echo $softwarename; ?><br/>
<strong>Item Rendering Software Version</strong>:  <?php echo $softwareversion; ?><br/>
<strong>Item Rendering Software Note</strong>:  
<?php 
if ($softwareid != NULL) {
$tsqlS = "SELECT SoftwareNote FROM Software WHERE SoftwareId = $softwareid";
$stmt = sqlsrv_query( $conn, $tsqlS, $params);

while ($rr=sqlsrv_fetch_array($stmt, SQLSRV_FETCH_BOTH)){
	echo $rr[0];
}
}
 ?>
 </p>

<p align="left"><strong>Item Technical Infrastructure</strong>: <?php echo $technicalinfrastructure; ?></p>

</td>
<?php 
	if (($readytoingest == 5) or ($readytoingest == 3)) { 
	echo "<td width=\"70%\" valign=\"top\">";
$len = strlen($dropboxPathToStrip);
$path = substr($directory, $len); 
$pathfixed = str_replace("\\", "/", $path);
$path2 = "data/";
$url = $manifestURL.$pathfixed.$path2.$receivedfilename;
  echo "<iframe id=\"iframe\" name=\"iframe\" width=\"100%\" height=\"600px\" src=\"$url\">";
  echo "<a href=\"";
  echo $url;
  echo "\">";
  echo "$url";
  echo "</a>";
    echo "</iframe>";
    }
echo "</td>";
echo "</tr>";
sqlsrv_close( $conn);
?>
</table>
</body>
</html>